﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Text;
using System.Net.Mail;
using System.Net;

namespace FilStartUps.Helper
{
    public class Emailer
    {

        public static void SendSMTPServer(string emailAddress, string emailBody)
        {
            SmtpClient client = new SmtpClient();
            client.Credentials = new NetworkCredential("webmaster@filstartups.com", "pB123456!");
            client.Port = 26;
            client.Host = "mail.filstartups.com";
            client.EnableSsl = false;

            MailAddress maFrom = new MailAddress("filstartups@yahoo.com", "FilStartUps", Encoding.UTF8),
                    maTo = new MailAddress(emailAddress);
            MailMessage msg = new MailMessage(maFrom, maTo);
            msg.Subject = "FilStartUps Confirmation Message";

            msg.Body = emailBody.ToString();
            msg.BodyEncoding = Encoding.UTF8;
            msg.IsBodyHtml = true;

            client.Send(msg);

        }

        public static void SendFilStartUpsRegistrationEmail(string emailAddress, string password,
                        string firstName, string lastName, string activationKey)
        {

            var emailBody = new StringBuilder();
            emailBody.Clear();

            emailBody.Append("<span style='font-size: 10pt;'><span style='font-size: 10pt;'><span style='font-family: Verdana; font-size: 10pt;'>");
            emailBody.Append("Hi " + firstName.ToUpper() + " " + lastName.ToUpper() + ",");
            emailBody.Append("</span><br style='font-family: Verdana;' /><br style='font-family: Verdana;' /><span style='font-family: Verdana; font-size: 10pt;'>");
            emailBody.Append("You're almost ready to get started, but first we need you to verify your account by clicking on the link below: </span><br style='font-family: Verdana;' /><br style='font-family: Verdana;' /><span style='font-family: Verdana; font-size: 10pt;'><a href='");
            emailBody.Append("https://www.filstartups.com/activate.aspx?e=" + emailAddress + "&q=" + activationKey);
            emailBody.Append("' target='_blank'>");
            emailBody.Append("https://www.filstartups.com/activate.aspx?e=" + emailAddress + "&q=" + activationKey);
            emailBody.Append("<br/><br/>You will then be able to log into your account using the email<br/>");
            emailBody.Append(emailAddress + " and your chosen password.<br/>");
            emailBody.Append("</a></span><br style='font-family: Verdana;' /><br style='font-family: Verdana;' /><span style='font-family: Verdana; font-size: 10pt;'>For other information, you may also check <a href='");
            emailBody.Append("https://www.filstartups.com");
            emailBody.Append("' target='_blank'>");
            emailBody.Append("https://www.filstartups.com");
            emailBody.Append("</a><br /><br />Thank you,<br />Administrator<br />FilStartUps.com</span></span></span>");

            SendSMTPServer(emailAddress, emailBody.ToString());
        }
    }
}